import math
import os
import re
import struct
import threading
from collections import defaultdict
from time import sleep

import pandas as pd
import numpy as np
import time
from commen.log import Logger
import openpyxl
import datetime
import commen.config


def percentage_error(data_error, total, sheet_obj):
    dict_percentage = {}
    for i in range(8, 100):
        key = sheet_obj.cell(1, i).value
        if key == "差异项":
            break
        if data_error.get(key):
            dict_percentage[key] = f"{key}的正确率：{(data_error.get(key) / total) * 100}%"
            print(f"{key}的正确率：{100 - round((data_error.get(key) / total) * 100, 2)}%")
        else:
            dict_percentage[key] = f"{key}的正确率：100%"
            print(f"{key}的正确率：100%")


def ImuDatacontinuity():
    # ---------读取config文件获取筛选字段内容--------------------------
    mpukey = commen.config.global_config.getRaw('keywords', 'suanfains')
    caninskey = commen.config.global_config.getRaw('keywords', 'cankeyins')

    # ---------读取config文件获取筛选字段内容--------------------------
    logger = Logger(logger='TestMylog').getlog()
    # -----------------------创建excel--------------------------------------------
    # 获取当前时间
    time_now = time.strftime("%Y%m%d-%H%M", time.localtime())
    # 获取当前路径
    result_root = os.getcwd()
    root = os.getcwd()
    result_path = result_root + r'\result' + "\\" + time_now
    log_path = root + r'\original-logfile' + '\\'
    # -----遍历对比log路径获取要对比的文件名路径信息----------------------
    for root, dirs, files in os.walk(log_path):
        for file in files:
            if "Data" in file:
                aa = os.path.join(root, file)
            if "can" in file:
                bb = os.path.join(root, file)

    # -----遍历对比log路径获取要对比的文件名路径信息----------------------
    book = openpyxl.Workbook()  # 打开一个将写的文件
    sheet = book.create_sheet(index=0)  # 在将写的文件创建sheet
    saveExcel = result_path + "INS数据准确性验证.xlsx"
    sheet.cell(1, 2).value = "mpu上INS数据的系统时间"
    sheet.cell(1, 3).value = "can上INS数据系统时间"
    sheet.cell(1, 4).value = "mpu上INS数据内容"
    sheet.cell(1, 5).value = "can上INS数据内容"
    sheet.cell(1, 6).value = "对比数据信息"
    sheet.cell(1, 7).value = "数据是否一致"
    sheet.cell(1, 8).value = "INS校准状态"
    sheet.cell(1, 9).value = "INS精度"
    sheet.cell(1, 10).value = "INS经度"
    sheet.cell(1, 11).value = "INS纬度"
    sheet.cell(1, 12).value = "INS高程"
    sheet.cell(1, 13).value = "INS东向速度"
    sheet.cell(1, 14).value = "INS北向速度"
    sheet.cell(1, 15).value = "INS地向速度"
    sheet.cell(1, 16).value = "INS东向速度精度"
    sheet.cell(1, 17).value = "INS地向速度精度"
    sheet.cell(1, 18).value = "INS北向速度精度"
    sheet.cell(1, 19).value = "INS经度精度"
    sheet.cell(1, 20).value = "INS纬度精度"
    sheet.cell(1, 21).value = "INS高程精度"
    sheet.cell(1, 22).value = "INS俯仰角"
    sheet.cell(1, 23).value = "INS横滚角"
    sheet.cell(1, 24).value = "INS航向角"
    sheet.cell(1, 25).value = "INS俯仰角精度"
    sheet.cell(1, 26).value = "INS横滚角精度"
    sheet.cell(1, 27).value = "INS航向角精度"
    sheet.cell(1, 28).value = "域控时间"
    sheet.cell(1, 29).value = "差异项"

    row = 1
    # -----------------------创建excel--------------------------------------------

    canfile = open(bb, 'r', encoding='gbk')  # 打开can.log目标文件
    dataprocfile = open(aa, 'r', encoding='UTF-8')  # 打开dataproc.log文件
    logger.info("打开目标文件")
    canlines = canfile.readlines()
    mpulines = dataprocfile.readlines()
    logger.info("获取内容")

    mpusystemtimelist = []  # mpu数据的系统时间
    cansystemtimelist = []  # can数据的系统时间
    mpumessagelist = []  # mpu数据内容
    canmessagelist = []  # can数据内容
    mpu_utctimelist = []  # mpuutc时间
    can_utctimelist = []  # canutc时间
    logger.info("开始逐行读取")

    for lines in mpulines:  # 对内容 进行逐行读取

        if mpukey in lines:  # 通过关键字获取数据信息并存入到list中

            mpusystemtime = lines[:lines.index("<thread")]
            mpusystemtimelist.append(mpusystemtime.rstrip())
            mpumessage = lines.split("+0:")
            mpumessage1 = mpumessage[1].lstrip().replace(" ", "").replace("-", "").replace("+10:", "").replace("+20:",
                                                                                                               "").replace(
                "+30:", "").replace("+40:", "").replace("+50:", "").replace("+60:", "").replace("+70:", "").replace(
                "+80:", "").replace("+90:", "").replace("+100:", "").replace(")", "")
            mpumessagelist.append(mpumessage1.rstrip())
            mpu_utctimelist.append(mpumessage1.rstrip()[5:16])

            # utc时间：str(mpumessage1.rstrip()[5:7])+" "+str(mpumessage1.rstrip()[7:9])+" "+str(mpumessage1.rstrip()[9:11])+" "+str(mpumessage1.rstrip()[11:13])+" "+str(mpumessage1.rstrip()[13:15])
    for canline in canlines:  # 对内容 进行逐行读取
        if caninskey in canline:  # 通过关键字获取数据信息并存入到list中
            systemtime = canline[:canline.index("Rx")]
            cansystemtimelist.append(systemtime.rstrip())
            canmessage = canline.split("s-fd-brs 64")
            canmessagelist.append(canmessage[1].replace(" ", ""))
            can_utctimelist.append(canmessage[1].replace(" ", "")[100:111])
    pic_dict = defaultdict(int)
    total = 0
    for i in mpu_utctimelist:
        wash_data = {}
        if i in can_utctimelist:
            logger.info("开始进行对比")
            row = row + 1
            mpu_number = mpu_utctimelist.index(str(i))
            can_number = can_utctimelist.index(str(i))
            try:
                total += 1
                # -----------------------------------------------INS校准状态（4.19 check）---------------------------------------------
                mpu_INS_status = mpumessagelist[mpu_number][16:18]
                mpu_INS_status_Decimal = int(mpu_INS_status, 16) << 7
                mpu_INS_status_Hexadecimal = str(hex(int(mpu_INS_status_Decimal))).replace("0x", "")
                can_INS_status_Hexadecimal = canmessagelist[can_number][4:6]
                can_INS_status_Decimal = int(str(canmessagelist[can_number][4:6]), 16)
                wash_data[f"{mpu_INS_status_Decimal=}"] = f"{can_INS_status_Decimal=}"
                # -----------------------------------------------INS精度（4.19 check）---------------------------------------------
                mpu_INS_precision = mpumessagelist[mpu_number][20:22]
                mpu_INS_precision_Decimal = int(mpu_INS_precision, 16) << 6
                mpu_INS_precision_Hexadecimal = str(hex(int(mpu_INS_precision_Decimal))).replace("0x", "")
                can_INS_precision_Hexadecimal = canmessagelist[can_number][72:74]
                can_INS_precision_Decimal = int(str(canmessagelist[can_number][72:74]), 16)
                wash_data[f"{mpu_INS_precision_Decimal=}"] = f"{can_INS_precision_Decimal=}"
                # -----------------------------------------------INS经度（4.19 check）---------------------------------------------
                mpu_INS_Longitude = mpumessagelist[mpu_number][22:38]
                mpu_INS_Longitude1 = struct.unpack("Q", (int(str(mpu_INS_Longitude), 16)).to_bytes(8, byteorder='big'))
                mpu_INS_Longitude2 = struct.unpack("q", (mpu_INS_Longitude1[0]).to_bytes(8, byteorder='big'))
                mpu_INS_Longitude3 = int(mpu_INS_Longitude2[0] / 13.097)
                mpu_INS_Longitude_Decimal = mpu_INS_Longitude3 << 2
                mpu_INS_Longitude_Hexadecimal = str(hex(int(mpu_INS_Longitude_Decimal))).replace("0x", "")
                can_INS_Longitude_Hexadecimal = canmessagelist[can_number][44:54]
                can_INS_Longitude_Decimal = int(str(canmessagelist[can_number][44:54]), 16)
                wash_data[f"{mpu_INS_Longitude_Decimal=}"] = f"{can_INS_Longitude_Decimal=}"
                # -----------------------------------------------INS纬度（4.19 check）---------------------------------------------

                mpu_INS_latitude = mpumessagelist[mpu_number][38:54]
                mpu_INS_latitude1 = struct.unpack("Q", (int(str(mpu_INS_latitude), 16)).to_bytes(8, byteorder='big'))
                mpu_INS_latitude2 = struct.unpack("q", (mpu_INS_latitude1[0]).to_bytes(8, byteorder='big'))
                mpu_INS_latitude3 = int(mpu_INS_latitude2[0] / 13.097)
                mpu_INS_latitude_Decimal = mpu_INS_latitude3 << 3
                mpu_INS_latitude_Hexadecimal = str(hex(int(mpu_INS_latitude_Decimal))).replace("0x", "")
                can_INS_latitude_Hexadecimal = canmessagelist[can_number][28:38]
                can_INS_latitude_Decimal = int(str(canmessagelist[can_number][28:38]), 16)
                wash_data[f"{mpu_INS_latitude_Decimal=}"] = f"{can_INS_latitude_Decimal=}"
                # -----------------------------------------------INS高程（4.19 check）---------------------------------------------
                mpu_Altitude_height = mpumessagelist[mpu_number][54:70]
                mpu_Altitude_height1 = struct.unpack("Q",
                                                     (int(str(mpu_Altitude_height), 16)).to_bytes(8, byteorder='big'))
                mpu_Altitude_height2 = struct.unpack("q", (mpu_Altitude_height1[0]).to_bytes(8, byteorder='big'))
                mpu_Altitude_height3 = int(mpu_Altitude_height2[0]) + 1000000000
                mpu_Altitude_height4 = int(mpu_Altitude_height3 / 2384.2)
                mpu_Altitude_height_Decimal = mpu_Altitude_height4 << 2
                mpu_Altitude_height_Hexadecimal = str(hex(int(mpu_Altitude_height_Decimal))).replace("0x", "")
                can_Altitude_height_Hexadecimal = canmessagelist[can_number][38:44]
                can_Altitude_height_Decimal = int(str(canmessagelist[can_number][38:44]), 16)
                wash_data[f"{mpu_Altitude_height_Decimal=}"] = f"{can_Altitude_height_Decimal=}"
                # -----------------------------------------------INS东向速度（4.19 check）---------------------------------------------
                mpu_Eastward_speed = mpumessagelist[mpu_number][70:78]
                mpu_Eastward_speed1 = struct.unpack("I",
                                                    (int(str(mpu_Eastward_speed), 16)).to_bytes(4, byteorder='big'))
                mpu_Eastward_speed2 = struct.unpack("i", (mpu_Eastward_speed1[0]).to_bytes(4, byteorder='big'))
                mpu_Eastward_speed3 = int(mpu_Eastward_speed2[0] / 1525.9)
                mpu_Eastward_speed_Decimal1 = int(str(mpu_Eastward_speed3 << 7))
                if "-" in str(mpu_Eastward_speed_Decimal1):
                    mpu_Eastward_speed_Decimal2 = int(str(mpu_Eastward_speed_Decimal1).replace("-", ""))
                    mpu_Eastward_speed_Decimal = int(str(bin(~mpu_Eastward_speed_Decimal2 + 1 & 0xfffffe)), 2)
                    mpu_Eastward_speed_Hexadecimal = hex(int(str(mpu_Eastward_speed_Decimal)))[2:].upper()
                else:
                    mpu_Eastward_speed_Decimal = mpu_Eastward_speed_Decimal1
                    mpu_Eastward_speed_Hexadecimal = hex(int(str(mpu_Eastward_speed_Decimal)))[2:].upper()
                can_Eastward_speed_Hexadecimal = canmessagelist[can_number][6:12]
                can_Eastward_speed_Decimal = int(str(canmessagelist[can_number][6:12]), 16)
                wash_data[f"{mpu_Eastward_speed_Decimal=}"] = f"{can_Eastward_speed_Decimal=}"
                # -----------------------------------------------INS北向速度（4.19 check）---------------------------------------------
                mpu_Northward_speed = mpumessagelist[mpu_number][78:86]
                mpu_Northward_speed1 = struct.unpack("I",
                                                     (int(str(mpu_Northward_speed), 16)).to_bytes(4, byteorder='big'))
                mpu_Northward_speed2 = struct.unpack("i", (mpu_Northward_speed1[0]).to_bytes(4, byteorder='big'))
                mpu_Northward_speed3 = int(mpu_Northward_speed2[0] / 1525.9)
                mpu_Northward_speed_Decimal1 = int(str(mpu_Northward_speed3 << 7))
                if "-" in str(mpu_Northward_speed_Decimal1):
                    mpu_Northward_speed_Decimal2 = int(str(mpu_Northward_speed_Decimal1).replace("-", ""))
                    mpu_Northward_speed_Decimal = int(str(bin(~mpu_Northward_speed_Decimal2 + 1 & 0xfffffe)), 2)
                    mpu_Northward_speed_Hexadecimal = hex(int(str(mpu_Northward_speed_Decimal)))[2:].upper()
                else:
                    mpu_Northward_speed_Decimal = mpu_Northward_speed_Decimal1
                    mpu_Northward_speed_Hexadecimal = hex(int(str(mpu_Northward_speed_Decimal)))[2:].upper()
                can_Northward_speed_Hexadecimal = canmessagelist[can_number][54:60]
                can_Northward_speed_Decimal = int(str(canmessagelist[can_number][54:60]), 16)
                wash_data[f"{mpu_Northward_speed_Decimal=}"] = f"{can_Northward_speed_Decimal=}"
                # -----------------------------------------------INS地向速度（4.19 check）-----------------------------------------------
                mpu_Downward_speed = mpumessagelist[mpu_number][86:94]
                mpu_Downward_speed1 = struct.unpack("I",
                                                    (int(str(mpu_Downward_speed), 16)).to_bytes(4, byteorder='big'))
                mpu_Downward_speed2 = struct.unpack("i", (mpu_Downward_speed1[0]).to_bytes(4, byteorder='big'))
                # mpu_Downward_speed3 = int(mpu_Downward_speed2[0] / 1525.9)
                mpu_Downward_speed3 = int(mpu_Downward_speed2[0] / 1831.1)
                # mpu_Downward_speed_Decimal1 = int(str(mpu_Downward_speed3 << 2))
                mpu_Downward_speed_Decimal1 = int(str(mpu_Downward_speed3 << 1))
                if "-" in str(mpu_Downward_speed_Decimal1):
                    mpu_Downward_speed_Decimal2 = int(str(mpu_Downward_speed_Decimal1).replace("-", ""))
                    mpu_Downward_speed_Decimal = int(str(bin(~mpu_Downward_speed_Decimal2 + 1 & 0xfffc)), 2)
                    mpu_Downward_speed_Hexadecimal = hex(int(str(mpu_Downward_speed_Decimal)))[2:].upper()
                else:
                    mpu_Downward_speed_Decimal = mpu_Downward_speed_Decimal1
                    mpu_Downward_speed_Hexadecimal = hex(int(str(mpu_Downward_speed_Decimal)))[2:].upper()
                can_Downward_speed_Hexadecimal = canmessagelist[can_number][16:20]
                can_Downward_speed_Decimal = int(str(canmessagelist[can_number][112:116]), 16)
                wash_data[f"{mpu_Downward_speed_Decimal=}"] = f"{can_Downward_speed_Decimal=}"

                # -----------------------------------------------INS东向速度精度（4.19 check）-----------------------------------------------
                mpu_INSinfINSEastSpdStd = mpumessagelist[mpu_number][94:102]
                mpu_INSinfINSEastSpdStd1 = struct.unpack("I", (int(str(mpu_INSinfINSEastSpdStd), 16)).to_bytes(4,
                                                                                                               byteorder='big'))
                mpu_INSinfINSEastSpdStd2 = struct.unpack("i",
                                                         (mpu_INSinfINSEastSpdStd1[0]).to_bytes(4, byteorder='big'))
                mpu_INSinfINSEastSpdStd3 = int(mpu_INSinfINSEastSpdStd2[0] / 1525.9)
                mpu_INSinfINSEastSpdStd_Decimal1 = int(str(mpu_INSinfINSEastSpdStd3 << 2))
                if "-" in str(mpu_INSinfINSEastSpdStd_Decimal1):
                    mpu_INSinfINSEastSpdStd_Decimal2 = int(str(mpu_INSinfINSEastSpdStd_Decimal1).replace("-", ""))
                    mpu_INSinfINSEastSpdStd_Decimal = int(str(bin(~mpu_INSinfINSEastSpdStd_Decimal2 + 1 & 0xfffc)), 2)
                    mpu_INSinfINSEastSpdStd_Hexadecimal = hex(int(str(mpu_INSinfINSEastSpdStd_Decimal)))[2:].upper()
                else:
                    mpu_INSinfINSEastSpdStd_Decimal = mpu_INSinfINSEastSpdStd_Decimal1
                    mpu_INSinfINSEastSpdStd_Hexadecimal = hex(int(str(mpu_INSinfINSEastSpdStd_Decimal)))[2:].upper()
                can_INSinfINSEastSpdStd_Hexadecimal = canmessagelist[can_number][12:16]
                can_INSinfINSEastSpdStd_Decimal = int(str(canmessagelist[can_number][12:16]), 16)
                wash_data[f"{mpu_INSinfINSEastSpdStd_Decimal=}"] = f"{can_INSinfINSEastSpdStd_Decimal=}"

                # -----------------------------------------------INS地向速度精度（4.19 check）-----------------------------------------------
                mpu_INSinfINSGroundSpdStd = mpumessagelist[mpu_number][102:110]
                mpu_INSinfINSGroundSpdStd1 = struct.unpack("I", (int(str(mpu_INSinfINSGroundSpdStd), 16)).to_bytes(4,
                                                                                                                   byteorder='big'))
                mpu_INSinfINSGroundSpdStd2 = struct.unpack("i",
                                                           (mpu_INSinfINSGroundSpdStd1[0]).to_bytes(4, byteorder='big'))
                mpu_INSinfINSGroundSpdStd3 = int(mpu_INSinfINSGroundSpdStd2[0] / 1525.9)
                mpu_INSinfINSGroundSpdStd_Decimal1 = int(str(mpu_INSinfINSGroundSpdStd3 << 2))
                if "-" in str(mpu_INSinfINSGroundSpdStd_Decimal1):
                    mpu_INSinfINSGroundSpdStd_Decimal2 = int(str(mpu_INSinfINSGroundSpdStd_Decimal1).replace("-", ""))
                    mpu_INSinfINSGroundSpdStd_Decimal = int(str(bin(~mpu_INSinfINSGroundSpdStd_Decimal2 + 1 & 0xfffc)),
                                                            2)
                    mpu_INSinfINSGroundSpdStd_Hexadecimal = hex(int(str(mpu_INSinfINSGroundSpdStd_Decimal)))[2:].upper()
                else:
                    mpu_INSinfINSGroundSpdStd_Decimal = mpu_INSinfINSGroundSpdStd_Decimal1
                    mpu_INSinfINSGroundSpdStd_Hexadecimal = hex(int(str(mpu_INSinfINSGroundSpdStd_Decimal)))[2:].upper()
                can_INSinfINSGroundSpdStd_Hexadecimal = canmessagelist[can_number][16:20]
                can_INSinfINSGroundSpdStd_Decimal = int(str(canmessagelist[can_number][16:20]), 16)
                wash_data[f"{mpu_INSinfINSGroundSpdStd_Decimal=}"] = f"{mpu_INSinfINSGroundSpdStd_Decimal=}"

                # -----------------------------------------------INS北向速度精度（4.19 check）-----------------------------------------------
                mpu_INSinfINSNorthSpdStd = mpumessagelist[mpu_number][110:118]
                mpu_INSinfINSNorthSpdStd1 = struct.unpack("I", (int(str(mpu_INSinfINSNorthSpdStd), 16)).to_bytes(4,
                                                                                                                 byteorder='big'))
                mpu_INSinfINSNorthSpdStd2 = struct.unpack("i",
                                                          (mpu_INSinfINSNorthSpdStd1[0]).to_bytes(4, byteorder='big'))
                mpu_INSinfINSNorthSpdStd3 = int(mpu_INSinfINSNorthSpdStd2[0] / 1525.9)
                mpu_INSinfINSNorthSpdStd_Decimal1 = int(str(mpu_INSinfINSNorthSpdStd3 << 2))
                if "-" in str(mpu_INSinfINSNorthSpdStd_Decimal1):
                    mpu_INSinfINSNorthSpdStd_Decimal2 = int(str(mpu_INSinfINSNorthSpdStd_Decimal1).replace("-", ""))
                    mpu_INSinfINSNorthSpdStd_Decimal = int(str(bin(~mpu_INSinfINSNorthSpdStd_Decimal2 + 1 & 0xfffc)), 2)
                    mpu_INSinfINSNorthSpdStd_Hexadecimal = hex(int(str(mpu_INSinfINSNorthSpdStd_Decimal)))[2:].upper()
                else:
                    mpu_INSinfINSNorthSpdStd_Decimal = mpu_INSinfINSNorthSpdStd_Decimal1
                    mpu_INSinfINSNorthSpdStd_Hexadecimal = hex(int(str(mpu_INSinfINSNorthSpdStd_Decimal)))[2:].upper()
                can_INSinfINSNorthSpdStd_Hexadecimal = canmessagelist[can_number][60:64]
                can_INSinfINSNorthSpdStd_Decimal = int(str(canmessagelist[can_number][60:64]), 16)
                wash_data[f"{mpu_INSinfINSNorthSpdStd_Decimal=}"] = f"{can_INSinfINSNorthSpdStd_Decimal=}"

                # -----------------------------------------------INS经度精度（4.19 check）-----------------------------------------------
                mpu_INSinfINSStdLon = mpumessagelist[mpu_number][118:126]
                mpu_INSinfINSStdLon1 = struct.unpack("I",
                                                     (int(str(mpu_INSinfINSStdLon), 16)).to_bytes(4, byteorder='big'))
                mpu_INSinfINSStdLon2 = struct.unpack("i", (mpu_INSinfINSStdLon1[0]).to_bytes(4, byteorder='big'))
                mpu_INSinfINSStdLon3 = int(mpu_INSinfINSStdLon2[0] / 1525.9)
                mpu_INSinfINSStdLon_Decimal = int(str(mpu_INSinfINSStdLon3 << 7).replace("-", ""))
                mpu_INSinfINSStdLon_Hexadecimal = str(hex(int(mpu_INSinfINSStdLon_Decimal))).replace("0x", "")
                can_INSinfINSStdLon_Hexadecimal = canmessagelist[can_number][94:100]
                can_INSinfINSStdLon_Decimal = int(str(canmessagelist[can_number][94:100]), 16)
                wash_data[f"{mpu_INSinfINSStdLon_Decimal=}"] = f"{can_INSinfINSStdLon_Decimal=}"

                # -----------------------------------------------INS纬度精度（4.19 check）-----------------------------------------------
                mpu_INSinfINSStdLat = mpumessagelist[mpu_number][126:134]
                mpu_INSinfINSStdLat1 = struct.unpack("I",
                                                     (int(str(mpu_INSinfINSStdLat), 16)).to_bytes(4, byteorder='big'))
                mpu_INSinfINSStdLat2 = struct.unpack("i", (mpu_INSinfINSStdLat1[0]).to_bytes(4, byteorder='big'))
                mpu_INSinfINSStdLat3 = int(mpu_INSinfINSStdLat2[0] / 1525.9)
                mpu_INSinfINSStdLat_Decimal = int(str(mpu_INSinfINSStdLat3 << 7).replace("-", ""))
                mpu_INSinfINSStdLat_Hexadecimal = str(hex(int(mpu_INSinfINSStdLat_Decimal))).replace("0x", "")
                can_INSinfINSStdLat_Hexadecimal = canmessagelist[can_number][82:88]
                can_INSinfINSStdLat_Decimal = int(str(canmessagelist[can_number][82:88]), 16)
                wash_data[f"{mpu_INSinfINSStdLat_Decimal=}"] = f"{can_INSinfINSStdLat_Decimal=}"

                # -----------------------------------------------INS高程精度（4.19 check）-----------------------------------------------
                mpu_INSinfINSStdLocatHeight = mpumessagelist[mpu_number][134:142]
                mpu_INSinfINSStdLocatHeight1 = struct.unpack("I",
                                                             (int(str(mpu_INSinfINSStdLocatHeight), 16)).to_bytes(4,
                                                                                                                  byteorder='big'))
                mpu_INSinfINSStdLocatHeight2 = struct.unpack("i", (mpu_INSinfINSStdLocatHeight1[0]).to_bytes(4,
                                                                                                             byteorder='big'))
                mpu_INSinfINSStdLocatHeight3 = int(mpu_INSinfINSStdLocatHeight2[0] / 1525.9)
                mpu_INSinfINSStdLocatHeight_Decimal = int(str(mpu_INSinfINSStdLocatHeight3 << 7).replace("-", ""))
                mpu_INSinfINSStdLocatHeight_Hexadecimal = str(hex(int(mpu_INSinfINSStdLocatHeight_Decimal))).replace(
                    "0x", "")
                can_INSinfINSStdLocatHeight_Hexadecimal = canmessagelist[can_number][88:94]
                can_INSinfINSStdLocatHeight_Decimal = int(str(canmessagelist[can_number][88:94]), 16)
                wash_data[f"{mpu_INSinfINSStdLocatHeight_Decimal=}"] = f"{can_INSinfINSStdLocatHeight_Decimal=}"

                # -----------------------------------------------INS俯仰角（4.19 check）-----------------------------------------------
                mpu_INSinfINSPitchAngle = mpumessagelist[mpu_number][142:150]
                mpu_INSinfINSPitchAngle1 = struct.unpack("I", (int(str(mpu_INSinfINSPitchAngle), 16)).to_bytes(4,
                                                                                                               byteorder='big'))
                mpu_INSinfINSPitchAngle2 = struct.unpack("i",
                                                         (mpu_INSinfINSPitchAngle1[0]).to_bytes(4, byteorder='big'))
                mpu_INSinfINSPitchAngle3 = int(mpu_INSinfINSPitchAngle2[0] / 10988)
                mpu_INSinfINSPitchAngle_Decimal = int(str(mpu_INSinfINSPitchAngle3 << 2).replace("-", ""))
                mpu_INSinfINSPitchAngle_Hexadecimal = str(hex(int(mpu_INSinfINSPitchAngle_Decimal))).replace("0x", "")
                can_INSinfINSPitchAngle_Hexadecimal = canmessagelist[can_number][64:68]
                can_INSinfINSPitchAngle_Decimal = int(str(canmessagelist[can_number][64:68]), 16)
                wash_data[f"{mpu_INSinfINSPitchAngle_Decimal=}"] = f"{can_INSinfINSPitchAngle_Decimal=}"

                # -----------------------------------------------INS横滚角（4.19 check）-----------------------------------------------
                mpu_INSinfINSRollAngle = mpumessagelist[mpu_number][150:158]
                mpu_INSinfINSRollAngle1 = struct.unpack("I", (int(str(mpu_INSinfINSRollAngle), 16)).to_bytes(4,
                                                                                                             byteorder='big'))
                mpu_INSinfINSRollAngle2 = struct.unpack("i", (mpu_INSinfINSRollAngle1[0]).to_bytes(4, byteorder='big'))
                mpu_INSinfINSRollAngle3 = int(mpu_INSinfINSRollAngle2[0] / 10987)
                mpu_INSinfINSRollAngle_Decimal = int(str(mpu_INSinfINSRollAngle3 << 1).replace("-", ""))
                mpu_INSinfINSRollAngle_Hexadecimal = str(hex(int(mpu_INSinfINSRollAngle_Decimal))).replace("0x", "")
                can_INSinfINSRollAngle_Hexadecimal = canmessagelist[can_number][74:78]
                can_INSinfINSRollAngle_Decimal = int(str(canmessagelist[can_number][74:78]), 16)
                wash_data[f"{mpu_INSinfINSRollAngle_Decimal=}"] = f"{can_INSinfINSRollAngle_Decimal=}"

                # -----------------------------------------------INS航向角（4.19 check）-----------------------------------------------
                mpu_INSinfINSHeadingAngle = mpumessagelist[mpu_number][158:166]
                mpu_INSinfINSHeadingAngle1 = struct.unpack("I", (int(str(mpu_INSinfINSHeadingAngle), 16)).to_bytes(4,
                                                                                                                   byteorder='big'))
                mpu_INSinfINSHeadingAngle2 = struct.unpack("i",
                                                           (mpu_INSinfINSHeadingAngle1[0]).to_bytes(4, byteorder='big'))
                mpu_INSinfINSHeadingAngle3 = int(mpu_INSinfINSHeadingAngle2[0] / 10986)
                mpu_INSinfINSHeadingAngle_Decimal = int(str(mpu_INSinfINSHeadingAngle3 << 1).replace("-", ""))
                mpu_INSinfINSHeadingAngle_Hexadecimal = str(hex(int(mpu_INSinfINSHeadingAngle_Decimal))).replace("0x",
                                                                                                                 "")
                can_INSinfINSHeadingAngle_Hexadecimal = canmessagelist[can_number][20:24]
                can_INSinfINSHeadingAngle_Decimal = int(str(canmessagelist[can_number][20:24]), 16)
                wash_data[f"{mpu_INSinfINSHeadingAngle_Decimal=}"] = f"{can_INSinfINSHeadingAngle_Decimal=}"

                # -----------------------------------------------INS俯仰角精度（4.19 check）-----------------------------------------------
                mpu_INSinfINSPitchAngleStd = mpumessagelist[mpu_number][166:174]
                mpu_INSinfINSPitchAngleStd1 = struct.unpack("I", (int(str(mpu_INSinfINSPitchAngleStd), 16)).to_bytes(4,
                                                                                                                     byteorder='big'))
                mpu_INSinfINSPitchAngleStd2 = struct.unpack("i", (mpu_INSinfINSPitchAngleStd1[0]).to_bytes(4,
                                                                                                           byteorder='big'))
                mpu_INSinfINSPitchAngleStd3 = int(mpu_INSinfINSPitchAngleStd2[0] / 10988)
                mpu_INSinfINSPitchAngleStd_Decimal = int(str(mpu_INSinfINSPitchAngleStd3 << 2).replace("-", ""))
                mpu_INSinfINSPitchAngleStd_Hexadecimal = str(hex(int(mpu_INSinfINSPitchAngleStd_Decimal))).replace("0x",
                                                                                                                   "")
                can_INSinfINSPitchAngleStd_Hexadecimal = canmessagelist[can_number][68:72]
                can_INSinfINSPitchAngleStd_Decimal = int(str(canmessagelist[can_number][68:72]), 16)
                wash_data[f"{mpu_INSinfINSPitchAngleStd_Decimal=}"] = f"{can_INSinfINSPitchAngleStd_Decimal=}"

                # -----------------------------------------------INS横滚角精度（4.19 check）-----------------------------------------------
                mpu_INSinfINSRollAngleStd = mpumessagelist[mpu_number][174:182]
                mpu_INSinfINSRollAngleStd1 = struct.unpack("I", (int(str(mpu_INSinfINSRollAngleStd), 16)).to_bytes(4,
                                                                                                                   byteorder='big'))
                mpu_INSinfINSRollAngleStd2 = struct.unpack("i",
                                                           (mpu_INSinfINSRollAngleStd1[0]).to_bytes(4, byteorder='big'))
                mpu_INSinfINSRollAngleStd3 = int(mpu_INSinfINSRollAngleStd2[0] / 10987)
                mpu_INSinfINSRollAngleStd_Decimal = int(str(mpu_INSinfINSRollAngleStd3 << 1).replace("-", ""))
                mpu_INSinfINSRollAngleStd_Hexadecimal = str(hex(int(mpu_INSinfINSRollAngleStd_Decimal))).replace("0x",
                                                                                                                 "")
                can_INSinfINSRollAngleStd_Hexadecimal = canmessagelist[can_number][78:82]
                can_INSinfINSRollAngleStd_Decimal = int(str(canmessagelist[can_number][78:82]), 16)
                wash_data[f"{mpu_INSinfINSRollAngleStd_Decimal=}"] = f"{can_INSinfINSRollAngleStd_Decimal=}"

                # -----------------------------------------------INS航向角精度（4.19 check）-----------------------------------------------
                mpu_INSinfINSHeadingAngleStd = mpumessagelist[mpu_number][182:190]
                mpu_INSinfINSHeadingAngleStd1 = struct.unpack("I",
                                                              (int(str(mpu_INSinfINSHeadingAngleStd), 16)).to_bytes(4,
                                                                                                                    byteorder='big'))
                mpu_INSinfINSHeadingAngleStd2 = struct.unpack("i", (mpu_INSinfINSHeadingAngleStd1[0]).to_bytes(4,
                                                                                                               byteorder='big'))
                mpu_INSinfINSHeadingAngleStd3 = int(mpu_INSinfINSHeadingAngleStd2[0] / 10987)
                mpu_INSinfINSHeadingAngleStd_Decimal = int(str(mpu_INSinfINSHeadingAngleStd3 << 1).replace("-", ""))
                mpu_INSinfINSHeadingAngleStd_Hexadecimal = str(hex(int(mpu_INSinfINSHeadingAngleStd_Decimal))).replace(
                    "0x", "")
                can_INSinfINSHeadingAngleStd_Hexadecimal = canmessagelist[can_number][24:28]
                can_INSinfINSHeadingAngleStd_Decimal = int(str(canmessagelist[can_number][24:28]), 16)
                wash_data[f"{mpu_INSinfINSHeadingAngleStd_Decimal=}"] = f"{can_INSinfINSHeadingAngleStd_Decimal=}"
            except:
                continue

            # -----------------------------------------------域控时间-----------------------------------------------
            mpu_INSinfINSTimestamp = mpumessagelist[mpu_number][190:202]
            can_INSinfINSTimestamp = canmessagelist[can_number][116:128]
            wash_data[f"{mpu_INSinfINSTimestamp=}"] = f"{can_INSinfINSTimestamp=}"
            if mpu_INS_status_Decimal == can_INS_status_Decimal and mpu_INS_precision_Decimal == can_INS_precision_Decimal and mpu_INS_Longitude_Decimal == can_INS_Longitude_Decimal and mpu_INS_latitude_Decimal == can_INS_latitude_Decimal and mpu_Altitude_height_Decimal == can_Altitude_height_Decimal and mpu_Eastward_speed_Decimal == can_Eastward_speed_Decimal and mpu_Northward_speed_Decimal == can_Northward_speed_Decimal and mpu_Downward_speed_Decimal == can_Downward_speed_Decimal and mpu_INSinfINSEastSpdStd_Decimal == can_INSinfINSEastSpdStd_Decimal and mpu_INSinfINSGroundSpdStd_Decimal == can_INSinfINSGroundSpdStd_Decimal and mpu_INSinfINSNorthSpdStd_Decimal == can_INSinfINSNorthSpdStd_Decimal and mpu_INSinfINSStdLon_Decimal == can_INSinfINSStdLon_Decimal and mpu_INSinfINSStdLat_Decimal == can_INSinfINSStdLat_Decimal and mpu_INSinfINSStdLocatHeight_Decimal == can_INSinfINSStdLocatHeight_Decimal and mpu_INSinfINSPitchAngle_Decimal == can_INSinfINSPitchAngle_Decimal and mpu_INSinfINSRollAngle_Decimal == can_INSinfINSRollAngle_Decimal and mpu_INSinfINSHeadingAngle_Decimal == can_INSinfINSHeadingAngle_Decimal and mpu_INSinfINSPitchAngleStd_Decimal == can_INSinfINSPitchAngleStd_Decimal and mpu_INSinfINSRollAngleStd_Decimal == can_INSinfINSRollAngleStd_Decimal and mpu_INSinfINSHeadingAngleStd_Decimal == can_INSinfINSHeadingAngleStd_Decimal and mpu_INSinfINSTimestamp == can_INSinfINSTimestamp:
                sheet.cell(row, 2).value = mpusystemtimelist[mpu_number]
                sheet.cell(row, 3).value = cansystemtimelist[can_number]
                sheet.cell(row, 4).value = mpumessagelist[mpu_number]
                sheet.cell(row, 5).value = canmessagelist[can_number]
                # sheet.cell(row, 6).value = "mpu_INS_status_Hexadecimal:" + mpu_INS_status_Hexadecimal +'\r\n'+"can_INS_status_Hexadecimal:"+ can_INS_status_Hexadecimal +'\r\n'+"mpu_INS_precision_Hexadecimal:"+ mpu_INS_precision_Hexadecimal +'\r\n'+"can_INS_precision_Hexadecimal:" + can_INS_precision_Hexadecimal +'\r\n'+"mpu_INS_Longitude_Hexadecimal:"+ mpu_INS_Longitude_Hexadecimal +'\r\n'+ "can_INS_Longitude_Hexadecimal:"+can_INS_Longitude_Hexadecimal +'\r\n'+"mpu_INS_latitude_Hexadecimal:" + mpu_INS_latitude_Hexadecimal+'\r\n'+ "can_INS_latitude_Hexadecimal:" +can_INS_latitude_Hexadecimal +'\r\n'+"mpu_Altitude_height_Hexadecimal:"+ mpu_Altitude_height_Hexadecimal +'\r\n'+ "can_Altitude_height_Hexadecimal:" +  can_Altitude_height_Hexadecimal +'\r\n'+ "mpu_Eastward_speed_Hexadecimal:" +  mpu_Eastward_speed_Hexadecimal +'\r\n'+ "can_Eastward_speed_Hexadecimal:" + can_Eastward_speed_Hexadecimal +'\r\n'+ "mpu_Northward_speed_Hexadecimal:" + mpu_Northward_speed_Hexadecimal +'\r\n'+ "can_Northward_speed_Hexadecimal:" + can_Northward_speed_Hexadecimal +'\r\n'+ "mpu_Downward_speed_Hexadecimal:" + mpu_Downward_speed_Hexadecimal +'\r\n'+ "can_Downward_speed_Hexadecimal:" + can_Downward_speed_Hexadecimal +'\r\n'+ "mpu_INSinfINSEastSpdStd_Hexadecimal:" +  mpu_INSinfINSEastSpdStd_Hexadecimal +'\r\n'+ "can_INSinfINSEastSpdStd_Hexadecimal:" + can_INSinfINSEastSpdStd_Hexadecimal +'\r\n'+"mpu_INSinfINSGroundSpdStd_Hexadecimal:" + mpu_INSinfINSGroundSpdStd_Hexadecimal +'\r\n'+ "can_INSinfINSGroundSpdStd_Hexadecimal:" + can_INSinfINSGroundSpdStd_Hexadecimal +'\r\n'+"mpu_INSinfINSNorthSpdStd_Hexadecimal:" + mpu_INSinfINSNorthSpdStd_Hexadecimal +'\r\n'+ "can_INSinfINSNorthSpdStd_Hexadecimal:" + can_INSinfINSNorthSpdStd_Hexadecimal +'\r\n'+ "mpu_INSinfINSStdLon_Hexadecimal:" +  mpu_INSinfINSStdLon_Hexadecimal +'\r\n'+ "can_INSinfINSStdLon_Hexadecimal:" + can_INSinfINSStdLon_Hexadecimal +'\r\n'+"mpu_INSinfINSStdLat_Hexadecimal:" + mpu_INSinfINSStdLat_Hexadecimal +'\r\n'+ "can_INSinfINSStdLat_Hexadecimal:" + can_INSinfINSStdLat_Hexadecimal +'\r\n'+"mpu_INSinfINSStdLocatHeight_Hexadecimal:"+ mpu_INSinfINSStdLocatHeight_Hexadecimal +'\r\n'+ "can_INSinfINSStdLocatHeight_Hexadecimal:"+ can_INSinfINSStdLocatHeight_Hexadecimal +'\r\n'+ "mpu_INSinfINSPitchAngle_Hexadecimal:" + mpu_INSinfINSPitchAngle_Hexadecimal +'\r\n'+ "can_INSinfINSPitchAngle_Hexadecimal:" + can_INSinfINSPitchAngle_Hexadecimal +'\r\n'+ "mpu_INSinfINSRollAngle_Hexadecimal:" + mpu_INSinfINSRollAngle_Hexadecimal +'\r\n'+ "can_INSinfINSRollAngle_Hexadecimal:" + can_INSinfINSRollAngle_Hexadecimal +'\r\n'+ "mpu_INSinfINSHeadingAngle_Hexadecimal:" + mpu_INSinfINSHeadingAngle_Hexadecimal +'\r\n'+ "can_INSinfINSHeadingAngle_Hexadecimal:"+ can_INSinfINSHeadingAngle_Hexadecimal +'\r\n'+ "mpu_INSinfINSPitchAngleStd_Hexadecimal:" + mpu_INSinfINSPitchAngleStd_Hexadecimal +'\r\n'+ "can_INSinfINSPitchAngleStd_Hexadecimal:" + can_INSinfINSPitchAngleStd_Hexadecimal +'\r\n'+ "mpu_INSinfINSRollAngleStd_Hexadecimal:" + mpu_INSinfINSRollAngleStd_Hexadecimal +'\r\n'+ "can_INSinfINSRollAngleStd_Hexadecimal"+ can_INSinfINSRollAngleStd_Hexadecimal +'\r\n'+ "mpu_INSinfINSHeadingAngleStd_Hexadecimal:" + mpu_INSinfINSHeadingAngleStd_Hexadecimal +'\r\n'+ "can_INSinfINSHeadingAngleStd_Hexadecimal:" + can_INSinfINSHeadingAngleStd_Hexadecimal +'\r\n'+ "mpu_INSinfINSTimestamp:" + mpu_INSinfINSTimestamp +'\r\n'+"can_INSinfINSTimestamp:"+ can_INSinfINSTimestamp
                sheet.cell(row, 6).value = "str(mpu_INS_status_Decimal):" + str(
                    str(mpu_INS_status_Decimal)) + '\r\n' + "str(can_INS_status_Decimal):" + str(
                    str(can_INS_status_Decimal)) + '\r\n' + "str(mpu_INS_precision_Decimal):" + str(
                    str(mpu_INS_precision_Decimal)) + '\r\n' + "str(can_INS_precision_Decimal):" + str(
                    str(can_INS_precision_Decimal)) + '\r\n' + "str(mpu_INS_Longitude_Decimal):" + str(
                    mpu_INS_Longitude_Decimal) + '\r\n' + "str(can_INS_Longitude_Decimal):" + str(
                    can_INS_Longitude_Decimal) + '\r\n' + "str(mpu_INS_latitude_Decimal):" + str(
                    mpu_INS_latitude_Decimal) + '\r\n' + "str(can_INS_latitude_Decimal):" + str(
                    can_INS_latitude_Decimal) + '\r\n' + "str(mpu_Altitude_height_Decimal):" + str(
                    mpu_Altitude_height_Decimal) + '\r\n' + "str(can_Altitude_height_Decimal):" + str(
                    can_Altitude_height_Decimal) + '\r\n' + "str(mpu_Eastward_speed_Decimal):" + str(
                    mpu_Eastward_speed_Decimal) + '\r\n' + "str(can_Eastward_speed_Decimal):" + str(
                    can_Eastward_speed_Decimal) + '\r\n' + "str(mpu_Northward_speed_Decimal):" + str(
                    mpu_Northward_speed_Decimal) + '\r\n' + "str(can_Northward_speed_Decimal):" + str(
                    can_Northward_speed_Decimal) + '\r\n' + "str(mpu_Downward_speed_Decimal):" + str(
                    mpu_Downward_speed_Decimal) + '\r\n' + "str(can_Downward_speed_Decimal):" + str(
                    can_Downward_speed_Decimal) + '\r\n' + "str(mpu_INSinfINSEastSpdStd_Decimal):" + str(
                    mpu_INSinfINSEastSpdStd_Decimal) + '\r\n' + "str(can_INSinfINSEastSpdStd_Decimal):" + str(
                    can_INSinfINSEastSpdStd_Decimal) + '\r\n' + "str(mpu_INSinfINSGroundSpdStd_Decimal):" + str(
                    mpu_INSinfINSGroundSpdStd_Decimal) + '\r\n' + "str(can_INSinfINSGroundSpdStd_Decimal):" + str(
                    can_INSinfINSGroundSpdStd_Decimal) + '\r\n' + "str(mpu_INSinfINSNorthSpdStd_Decimal):" + str(
                    mpu_INSinfINSNorthSpdStd_Decimal) + '\r\n' + "str(can_INSinfINSNorthSpdStd_Decimal):" + str(
                    can_INSinfINSNorthSpdStd_Decimal) + '\r\n' + "str(mpu_INSinfINSStdLon_Decimal):" + str(
                    mpu_INSinfINSStdLon_Decimal) + '\r\n' + "str(can_INSinfINSStdLon_Decimal):" + str(
                    can_INSinfINSStdLon_Decimal) + '\r\n' + "str(mpu_INSinfINSStdLat_Decimal):" + str(
                    mpu_INSinfINSStdLat_Decimal) + '\r\n' + "str(can_INSinfINSStdLat_Decimal):" + str(
                    can_INSinfINSStdLat_Decimal) + '\r\n' + "str(mpu_INSinfINSStdLocatHeight_Decimal):" + str(
                    mpu_INSinfINSStdLocatHeight_Decimal) + '\r\n' + "str(can_INSinfINSStdLocatHeight_Decimal):" + str(
                    can_INSinfINSStdLocatHeight_Decimal) + '\r\n' + "str(mpu_INSinfINSPitchAngle_Decimal):" + str(
                    mpu_INSinfINSPitchAngle_Decimal) + '\r\n' + "str(can_INSinfINSPitchAngle_Decimal):" + str(
                    can_INSinfINSPitchAngle_Decimal) + '\r\n' + "str(mpu_INSinfINSRollAngle_Decimal):" + str(
                    mpu_INSinfINSRollAngle_Decimal) + '\r\n' + "str(can_INSinfINSRollAngle_Decimal):" + str(
                    can_INSinfINSRollAngle_Decimal) + '\r\n' + "str(mpu_INSinfINSHeadingAngle_Decimal):" + str(
                    mpu_INSinfINSHeadingAngle_Decimal) + '\r\n' + "str(can_INSinfINSHeadingAngle_Decimal):" + str(
                    can_INSinfINSHeadingAngle_Decimal) + '\r\n' + "str(mpu_INSinfINSPitchAngleStd_Decimal):" + str(
                    mpu_INSinfINSPitchAngleStd_Decimal) + '\r\n' + "str(can_INSinfINSPitchAngleStd_Decimal):" + str(
                    can_INSinfINSPitchAngleStd_Decimal) + '\r\n' + "str(mpu_INSinfINSRollAngleStd_Decimal):" + str(
                    mpu_INSinfINSRollAngleStd_Decimal) + '\r\n' + "str(can_INSinfINSRollAngleStd_Decimal)" + str(
                    can_INSinfINSRollAngleStd_Decimal) + '\r\n' + "str(mpu_INSinfINSHeadingAngleStd_Decimal):" + str(
                    mpu_INSinfINSHeadingAngleStd_Decimal) + '\r\n' + "str(can_INSinfINSHeadingAngleStd_Decimal):" + str(
                    can_INSinfINSHeadingAngleStd_Decimal) + '\r\n' + "str(mpu_INSinfINSTimestamp:" + mpu_INSinfINSTimestamp + '\r\n' + "str(can_INSinfINSTimestamp:" + can_INSinfINSTimestamp
                sheet.cell(row, 7).value = "是"
            else:
                sheet.cell(row, 2).value = mpusystemtimelist[mpu_number]
                sheet.cell(row, 3).value = cansystemtimelist[can_number]
                sheet.cell(row, 4).value = mpumessagelist[mpu_number]
                sheet.cell(row, 5).value = canmessagelist[can_number]
                # sheet.cell(row, 6).value = "mpu_INS_status_Hexadecimal:" + mpu_INS_status_Hexadecimal +'\r\n'+"can_INS_status_Hexadecimal:"+ can_INS_status_Hexadecimal +'\r\n'+"mpu_INS_precision_Hexadecimal:"+ mpu_INS_precision_Hexadecimal +'\r\n'+"can_INS_precision_Hexadecimal:" + can_INS_precision_Hexadecimal +'\r\n'+"mpu_INS_Longitude_Hexadecimal:"+ mpu_INS_Longitude_Hexadecimal +'\r\n'+ "can_INS_Longitude_Hexadecimal:"+can_INS_Longitude_Hexadecimal +'\r\n'+"mpu_INS_latitude_Hexadecimal:" + mpu_INS_latitude_Hexadecimal+'\r\n'+ "can_INS_latitude_Hexadecimal:" +can_INS_latitude_Hexadecimal +'\r\n'+"mpu_Altitude_height_Hexadecimal:"+ mpu_Altitude_height_Hexadecimal +'\r\n'+ "can_Altitude_height_Hexadecimal:" +  can_Altitude_height_Hexadecimal +'\r\n'+ "mpu_Eastward_speed_Hexadecimal:" +  mpu_Eastward_speed_Hexadecimal +'\r\n'+ "can_Eastward_speed_Hexadecimal:" + can_Eastward_speed_Hexadecimal +'\r\n'+ "mpu_Northward_speed_Hexadecimal:" + mpu_Northward_speed_Hexadecimal +'\r\n'+ "can_Northward_speed_Hexadecimal:" + can_Northward_speed_Hexadecimal +'\r\n'+ "mpu_Downward_speed_Hexadecimal:" + mpu_Downward_speed_Hexadecimal +'\r\n'+ "can_Downward_speed_Hexadecimal:" + can_Downward_speed_Hexadecimal +'\r\n'+ "mpu_INSinfINSEastSpdStd_Hexadecimal:" +  mpu_INSinfINSEastSpdStd_Hexadecimal +'\r\n'+ "can_INSinfINSEastSpdStd_Hexadecimal:" + can_INSinfINSEastSpdStd_Hexadecimal +'\r\n'+"mpu_INSinfINSGroundSpdStd_Hexadecimal:" + mpu_INSinfINSGroundSpdStd_Hexadecimal +'\r\n'+ "can_INSinfINSGroundSpdStd_Hexadecimal:" + can_INSinfINSGroundSpdStd_Hexadecimal +'\r\n'+"mpu_INSinfINSNorthSpdStd_Hexadecimal:" + mpu_INSinfINSNorthSpdStd_Hexadecimal +'\r\n'+ "can_INSinfINSNorthSpdStd_Hexadecimal:" + can_INSinfINSNorthSpdStd_Hexadecimal +'\r\n'+ "mpu_INSinfINSStdLon_Hexadecimal:" +  mpu_INSinfINSStdLon_Hexadecimal +'\r\n'+ "can_INSinfINSStdLon_Hexadecimal:" + can_INSinfINSStdLon_Hexadecimal +'\r\n'+"mpu_INSinfINSStdLat_Hexadecimal:" + mpu_INSinfINSStdLat_Hexadecimal +'\r\n'+ "can_INSinfINSStdLat_Hexadecimal:" + can_INSinfINSStdLat_Hexadecimal +'\r\n'+"mpu_INSinfINSStdLocatHeight_Hexadecimal:"+ mpu_INSinfINSStdLocatHeight_Hexadecimal +'\r\n'+ "can_INSinfINSStdLocatHeight_Hexadecimal:"+ can_INSinfINSStdLocatHeight_Hexadecimal +'\r\n'+ "mpu_INSinfINSPitchAngle_Hexadecimal:" + mpu_INSinfINSPitchAngle_Hexadecimal +'\r\n'+ "can_INSinfINSPitchAngle_Hexadecimal:" + can_INSinfINSPitchAngle_Hexadecimal +'\r\n'+ "mpu_INSinfINSRollAngle_Hexadecimal:" + mpu_INSinfINSRollAngle_Hexadecimal +'\r\n'+ "can_INSinfINSRollAngle_Hexadecimal:" + can_INSinfINSRollAngle_Hexadecimal +'\r\n'+ "mpu_INSinfINSHeadingAngle_Hexadecimal:" + mpu_INSinfINSHeadingAngle_Hexadecimal +'\r\n'+ "can_INSinfINSHeadingAngle_Hexadecimal:"+ can_INSinfINSHeadingAngle_Hexadecimal +'\r\n'+ "mpu_INSinfINSPitchAngleStd_Hexadecimal:" + mpu_INSinfINSPitchAngleStd_Hexadecimal +'\r\n'+ "can_INSinfINSPitchAngleStd_Hexadecimal:" + can_INSinfINSPitchAngleStd_Hexadecimal +'\r\n'+ "mpu_INSinfINSRollAngleStd_Hexadecimal:" + mpu_INSinfINSRollAngleStd_Hexadecimal +'\r\n'+ "can_INSinfINSRollAngleStd_Hexadecimal"+ can_INSinfINSRollAngleStd_Hexadecimal +'\r\n'+ "mpu_INSinfINSHeadingAngleStd_Hexadecimal:" + mpu_INSinfINSHeadingAngleStd_Hexadecimal +'\r\n'+ "can_INSinfINSHeadingAngleStd_Hexadecimal:" + can_INSinfINSHeadingAngleStd_Hexadecimal +'\r\n'+ "mpu_INSinfINSTimestamp:" + mpu_INSinfINSTimestamp +'\r\n'+"can_INSinfINSTimestamp:"+ can_INSinfINSTimestamp
                sheet.cell(row, 6).value = "str(mpu_INS_status_Decimal):" + str(
                    str(mpu_INS_status_Decimal)) + '\r\n' + "str(can_INS_status_Decimal):" + str(
                    str(can_INS_status_Decimal)) + '\r\n' + "str(mpu_INS_precision_Decimal):" + str(
                    str(mpu_INS_precision_Decimal)) + '\r\n' + "str(can_INS_precision_Decimal):" + str(
                    str(can_INS_precision_Decimal)) + '\r\n' + "str(mpu_INS_Longitude_Decimal):" + str(
                    mpu_INS_Longitude_Decimal) + '\r\n' + "str(can_INS_Longitude_Decimal):" + str(
                    can_INS_Longitude_Decimal) + '\r\n' + "str(mpu_INS_latitude_Decimal):" + str(
                    mpu_INS_latitude_Decimal) + '\r\n' + "str(can_INS_latitude_Decimal):" + str(
                    can_INS_latitude_Decimal) + '\r\n' + "str(mpu_Altitude_height_Decimal):" + str(
                    mpu_Altitude_height_Decimal) + '\r\n' + "str(can_Altitude_height_Decimal):" + str(
                    can_Altitude_height_Decimal) + '\r\n' + "str(mpu_Eastward_speed_Decimal):" + str(
                    mpu_Eastward_speed_Decimal) + '\r\n' + "str(can_Eastward_speed_Decimal):" + str(
                    can_Eastward_speed_Decimal) + '\r\n' + "str(mpu_Northward_speed_Decimal):" + str(
                    mpu_Northward_speed_Decimal) + '\r\n' + "str(can_Northward_speed_Decimal):" + str(
                    can_Northward_speed_Decimal) + '\r\n' + "str(mpu_Downward_speed_Decimal):" + str(
                    mpu_Downward_speed_Decimal) + '\r\n' + "str(can_Downward_speed_Decimal):" + str(
                    can_Downward_speed_Decimal) + '\r\n' + "str(mpu_INSinfINSEastSpdStd_Decimal):" + str(
                    mpu_INSinfINSEastSpdStd_Decimal) + '\r\n' + "str(can_INSinfINSEastSpdStd_Decimal):" + str(
                    can_INSinfINSEastSpdStd_Decimal) + '\r\n' + "str(mpu_INSinfINSGroundSpdStd_Decimal):" + str(
                    mpu_INSinfINSGroundSpdStd_Decimal) + '\r\n' + "str(can_INSinfINSGroundSpdStd_Decimal):" + str(
                    can_INSinfINSGroundSpdStd_Decimal) + '\r\n' + "str(mpu_INSinfINSNorthSpdStd_Decimal):" + str(
                    mpu_INSinfINSNorthSpdStd_Decimal) + '\r\n' + "str(can_INSinfINSNorthSpdStd_Decimal):" + str(
                    can_INSinfINSNorthSpdStd_Decimal) + '\r\n' + "str(mpu_INSinfINSStdLon_Decimal):" + str(
                    mpu_INSinfINSStdLon_Decimal) + '\r\n' + "str(can_INSinfINSStdLon_Decimal):" + str(
                    can_INSinfINSStdLon_Decimal) + '\r\n' + "str(mpu_INSinfINSStdLat_Decimal):" + str(
                    mpu_INSinfINSStdLat_Decimal) + '\r\n' + "str(can_INSinfINSStdLat_Decimal):" + str(
                    can_INSinfINSStdLat_Decimal) + '\r\n' + "str(mpu_INSinfINSStdLocatHeight_Decimal):" + str(
                    mpu_INSinfINSStdLocatHeight_Decimal) + '\r\n' + "str(can_INSinfINSStdLocatHeight_Decimal):" + str(
                    can_INSinfINSStdLocatHeight_Decimal) + '\r\n' + "str(mpu_INSinfINSPitchAngle_Decimal):" + str(
                    mpu_INSinfINSPitchAngle_Decimal) + '\r\n' + "str(can_INSinfINSPitchAngle_Decimal):" + str(
                    can_INSinfINSPitchAngle_Decimal) + '\r\n' + "str(mpu_INSinfINSRollAngle_Decimal):" + str(
                    mpu_INSinfINSRollAngle_Decimal) + '\r\n' + "str(can_INSinfINSRollAngle_Decimal):" + str(
                    can_INSinfINSRollAngle_Decimal) + '\r\n' + "str(mpu_INSinfINSHeadingAngle_Decimal):" + str(
                    mpu_INSinfINSHeadingAngle_Decimal) + '\r\n' + "str(can_INSinfINSHeadingAngle_Decimal):" + str(
                    can_INSinfINSHeadingAngle_Decimal) + '\r\n' + "str(mpu_INSinfINSPitchAngleStd_Decimal):" + str(
                    mpu_INSinfINSPitchAngleStd_Decimal) + '\r\n' + "str(can_INSinfINSPitchAngleStd_Decimal):" + str(
                    can_INSinfINSPitchAngleStd_Decimal) + '\r\n' + "str(mpu_INSinfINSRollAngleStd_Decimal):" + str(
                    mpu_INSinfINSRollAngleStd_Decimal) + '\r\n' + "str(can_INSinfINSRollAngleStd_Decimal)" + str(
                    can_INSinfINSRollAngleStd_Decimal) + '\r\n' + "str(mpu_INSinfINSHeadingAngleStd_Decimal):" + str(
                    mpu_INSinfINSHeadingAngleStd_Decimal) + '\r\n' + "str(can_INSinfINSHeadingAngleStd_Decimal):" + str(
                    can_INSinfINSHeadingAngleStd_Decimal) + '\r\n' + "str(mpu_INSinfINSTimestamp:" + mpu_INSinfINSTimestamp + '\r\n' + "str(can_INSinfINSTimestamp:" + can_INSinfINSTimestamp
                sheet.cell(row, 7).value = "否"
            diff_list = []
            loc = 8
            for k, v in wash_data.items():
                if k.split("=")[1] == v.split("=")[1]:
                    sheet.cell(row, loc).value = True
                else:
                    sheet.cell(row, loc).value = False
                    diff_list.append(k)
                    diff_list.append(v)
                    pic_dict[sheet.cell(1, loc).value] += 1
                loc += 1
            sheet.cell(row, loc).value = "\r\n".join(diff_list)
    sleep(2)
    print(pic_dict, total)
    percentage_error(pic_dict, total, sheet)

    # ----------------------将对比的数据写入excel---------------------------------
    book.save(saveExcel)
    # ----------------------将对比的数据写入excel---------------------------------


ImuDatacontinuity()
